import { reactive, watchEffect } from 'vue';

export const useForm = (props, emits) => {
  const formData = reactive({
    formModel: {},
  });

  watchEffect(() => {
    formData.formModel = props.model;
  });

  const changeItem = e => {
    emits('change', formData.formModel);
  };
  const setFilesValue = values => {
    formData.formModel = {
      ...formData.formModel,
      ...values,
    };
  };
  const getFilesValue = () => {
    return formData.formModel;
  };
  return {
    formData,
    changeItem,
    setFilesValue,
    getFilesValue,
  };
};
